package com.jh.paymentchannel.payment;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.jh.paymentchannel.pojo.PaymentOrder;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author Yichuan
 * @version 1.0
 */
public class PaymentOrderDetail implements Serializable {

    private static final long serialVersionUID = -5200123503105488653L;

    public static List<PaymentOrderDetail> transform(List<PaymentOrder> orderList) {
        if (orderList == null || orderList.isEmpty()) {
            return ImmutableList.of();
        }
        List<PaymentOrderDetail> result = Lists.newLinkedList();
        for (PaymentOrder order: orderList) {
            result.add(PaymentOrderDetail.detail(order));
        }
        return result;
    }

    public static PaymentOrderDetail detail(PaymentOrder order) {
        PaymentOrderDetail detail = new PaymentOrderDetail();
        detail.setOrderId(order.getOrderId());
        detail.setAppId(order.getAppId());
        detail.setShopId(order.getShopId());
        detail.setShopName(order.getShopName());
        detail.setSubMchId(order.getSubMchId());
        detail.setNonceStr(order.getNonceStr());
        detail.setAmount(order.getTotalFee());
        detail.setBody(order.getBody());
        detail.setDetail(order.getDetail());
        detail.setOutTradeNo(order.getOutTradeNo());
        detail.setTradeNo(order.getTradeNo());
        detail.setOrderType(order.getOrderType());
        detail.setTypeName(order.getOrderType().getDesc());
        detail.setTradeStatus(order.getTradeStatus());
        detail.setStatusName(order.getTradeStatus().getDesc());
        detail.setTradeBank(order.getTradeBank());
        detail.setFeeType(order.getFeeType());
        detail.setPrepayId(order.getPrepayId());
        detail.setSpbillCreateIp(order.getSpbillCreateIp());
        detail.setUpdateTime(order.getUpdateTime());
        detail.setCreateTime(order.getCreateTime());
        return detail;
    }

    private long orderId;
    private String appId;
    private String shopId;
    private String shopName;
    private String subMchId;
    private String nonceStr;
    private BigDecimal amount;
    private String body;
    private String detail;
    private String outTradeNo;
    private String tradeNo;
    private OrderType orderType;
    private String typeName;
    private TradeStatus tradeStatus;
    private String statusName;
    private String tradeBank;
    private String feeType;
    private String prepayId;
    private String spbillCreateIp;
    private Date updateTime;
    private Date createTime;

    public PaymentOrderDetail() {
        super();
    }

    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public String getSubMchId() {
        return subMchId;
    }

    public void setSubMchId(String subMchId) {
        this.subMchId = subMchId;
    }

    public String getNonceStr() {
        return nonceStr;
    }

    public void setNonceStr(String nonceStr) {
        this.nonceStr = nonceStr;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public OrderType getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    public TradeStatus getTradeStatus() {
        return tradeStatus;
    }

    public void setTradeStatus(TradeStatus tradeStatus) {
        this.tradeStatus = tradeStatus;
    }

    public String getTradeBank() {
        return tradeBank;
    }

    public void setTradeBank(String tradeBank) {
        this.tradeBank = tradeBank;
    }

    public String getFeeType() {
        return feeType;
    }

    public void setFeeType(String feeType) {
        this.feeType = feeType;
    }

    public String getPrepayId() {
        return prepayId;
    }

    public void setPrepayId(String prepayId) {
        this.prepayId = prepayId;
    }

    public String getSpbillCreateIp() {
        return spbillCreateIp;
    }

    public void setSpbillCreateIp(String spbillCreateIp) {
        this.spbillCreateIp = spbillCreateIp;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getStatusName() {
        return statusName;
    }

    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
}
